import api from '@/util/api.js'

// 查询全部会员
async function findAll(params, page = 1, limit = 10) {
    let resp = await api({
        url: "/members",
        method: "GET",
        params: {
            ...params,
            page,
            limit
        }
    });

    return resp;
}

// 批量删除，默认以application/json格式传递数据
async function deleteByIds(ids) {
    let resp = await api({
        url: "/members",
        method: "DELETE",
        data: ids
    });

    return resp;
}

// 保存一个会员
async function save(member) {
    try {
        let resp = await api({
            url: "/members",
            method: "POST",
            data: member
        });
        return resp;
    } catch (error) {
        console.log(error)
    }
    return false;
}

// 修改一个会员
async function update(member) {
    let resp = await api({
        url: "/members",
        method: "PUT",
        data: member
    });

    return resp;
}

export {
    findAll, deleteByIds, save, update
}